package com.yue92.datalife.service.impl;

import com.yue92.datalife.model.RecordItemExtra;
import com.yue92.datalife.repository.RecordItemExtraRepository;
import com.yue92.datalife.service.AbstractDbService;
import com.yue92.datalife.service.IRecordItemExtraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordItemExtraServiceImpl extends AbstractDbService<RecordItemExtra, Long> implements IRecordItemExtraService {

    @Autowired
    private RecordItemExtraRepository recordItemExtraRepository;

    @Override
    public List<RecordItemExtra> getAllByRecordItemId(Long recordItemId) {
        return recordItemExtraRepository.getAllByRecordItemIdOrderByRecordDateAsc(recordItemId);
    }

    @Override
    public Boolean existsByRecordItemId(Long recordItemId) {
        return recordItemExtraRepository.existsByRecordItemId(recordItemId);
    }

    @Override
    public JpaRepository<RecordItemExtra, Long> getRepository() {
        return recordItemExtraRepository;
    }

    @Override
    protected Class<RecordItemExtra> getModelClass() {
        return RecordItemExtra.class;
    }
}
